/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Menus;

import Control.ButtonController;
import Control.GameController;
import ObjectPack.Save;
import UserInterface.Button;
import gleem.linalg.Vec4f;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;

/**
 * Menu de Save
 * @author Gustavo Buzogany Eboli
 */
public class SaveMenu extends Menu {

    TreeMap saves;

    public SaveMenu(GameController gc)
    {
        super(gc);

        boolean[] slots = new boolean[5];
        int i = 0;
        Integer auxkey;
        Save aux;
        Button saveSlot;

        ButtonController bc = new ButtonController(gc);

        saves = gc.getSm().getListaSaves();

        Set keys = saves.keySet();
        Iterator it = keys.iterator();
        while(it.hasNext())
        {
            auxkey = (Integer) it.next();

            aux = (Save) saves.get(auxkey);

            saveSlot = new Button("saveSlot"+aux.slot, 362, 400+40*aux.slot, 300, 30, "Slot "+aux.slot+" - "+aux.today+" - "+aux.now);
            saveSlot.setColor(new Vec4f(0.3f, 0.3f, 1.0f, 0.7f));

            buttonList.add(saveSlot);

            saveSlot.addButtonListener(bc);
            slots[aux.slot] = true;
            i++;
        }

        for (i = 0; i < 5; i++) {
            if (slots[i] == false) {
                saveSlot = new Button("saveSlot" + i, 362, 400 + 40 * i, 300, 30, "Slot " + i + " - Empty");
                saveSlot.setColor(new Vec4f(0.3f, 0.3f, 1.0f, 0.7f));

                buttonList.add(saveSlot);

                saveSlot.addButtonListener(bc);
            }
        }


            saveSlot = new Button("backToPause", 362, 640, 300, 30, "Cancel");
            saveSlot.setColor(new Vec4f(0.3f, 0.3f, 1.0f, 1.0f));

            buttonList.add(saveSlot);

            saveSlot.addButtonListener(bc);

    }

}
